package com.gyp.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gyp.entity.GySystemConfig;
import com.gyp.enums.SystemConfigEnum;
import com.gyp.mapper.user.SystemConfigMapper;
import com.gyp.service.SystemConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigMapper, GySystemConfig> implements SystemConfigService {
    @Override
    public Object getSystemConfig(SystemConfigEnum configCode) {
        GySystemConfig one = getOne(new LambdaQueryWrapper<GySystemConfig>()
                .eq(GySystemConfig::getConfigCode, configCode.getCode()));
        return one.getConfigValue();
    }

    @Override
    public void updateSystemConfig(SystemConfigEnum configCode, String value) {
        lambdaUpdate()
                .set(GySystemConfig::getConfigValue,value)
                .eq(GySystemConfig::getConfigCode,configCode.getCode())
                .update();
    }


}
